<template>
    <div>
        <h2>登录</h2>
        <table border="5">
            <tr>
                <td>账号</td>
                <td>
                    <input type="text" placeholder="请输入账号" v-model="info.Card">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="password" placeholder="请输入密码" v-model="info.Pwd">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="登录" @click="MemberLogin">
                </td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import{ref,reactive,onMounted}from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const router = useRouter();

const info =ref({
    Card:'',
    Pwd:'',
})

const MemberLogin=()=>{
    axios.get("https://localhost:7162/api/Member/MemberLogin",{
        params:{
            card:info.value.Card,
            pwd:info.value.Pwd,
        }
    })
    .then(res=>{
        if(res.data==-1){
            alert("用户名不存在");
            return;
        }
        else if(res.data==-2){
            alert("密码错误");
            return;
        }
        else if(res.data>0){
            alert("登录成功");
            router.push("MemberAdd");
        }
    })
}
</script>